include("shared.lua");
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
-- Setting up all the different properties of our melon.
ENT.Delay = 5.55;
ENT.Healthlol = 300;
ENT.FiringRange = 500;
ENT.NoMoveRange = 20;
ENT.DeathRadius = 400;
ENT.DeathMagnitude = 20;
ENT.MovingForce = 25;
ENT.MelonModel = "models/props_c17/FurnitureBoiler001a.mdl";
ENT.targets = {};
ENT.teams = {};

-- Now we tell the base class to set up the melon. Pay attention - the variables must be defined BEFORE calling Setup().
function ENT:Initialize()
	self:Setup();
	self.Entity:SetMaterial(nil);
local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake();
		phys:SetMass(1000);
	end
end

--No attacking or other thoughts function - this is a special warmelon, and as such, we want to override Think().
function ENT:DoAttacks ()
self:Clarity(self.targets, self.teams);
self.targets = {};
self.teams = {};
	local entz = ents.FindByClass("info_target");
	for k, v in pairs(entz) do
		if v.Warmelon then
			if (v:GetPos():Distance(self.Entity:GetPos())<self.FiringRange && v:GetParent():GetTable().Team == self.Team && v:GetParent():GetTable().Delay != 5.55) then
					local angle = v:GetParent():GetPos() - self.Entity:GetPos();
				  table.insert(self.targets, v);
			   	table.insert(self.teams, v:GetParent():GetTable().Delay);
              if (v:GetParent():GetTable().Delay ~= nil && v:GetParent():GetTable().Delay > 0.1) then
				  v:GetParent():GetTable().Delay = v:GetParent():GetTable().Delay * 0.75;
						local fx = EffectData();
						fx:SetOrigin(v:GetPos());
						util.Effect("johnny_leading", fx);
						end
			end
		end
	end
end

function ENT:Clarity (tar, tea)

	for k, v in pairs(tar) do
   	 v:GetParent():GetTable().Delay = table.remove(tea);
	end
end	